// index.js
Page({
  data:{
    activityList:[
      {
        id:0,
        title:"cehsi"
      }
    ]
  },

  onLoad(){
    var token = wx.getStorageSync('token')
    if(token != null && token != undefined && token != ''){
      this.searchData()
    }else{
      wx.reLaunch({
        url: '/pages/my/my',
        success(){
          wx.showToast({
            icon:"error",
            title: '请先登录',
          })
        }
      })
    }
  },
  onShow(){
    this.searchData()
  },
  searchData(){
    wx.$request(true,"/activity/findActivityList","GET",null) 
      .then(res=>{
        this.setData({
          activityList: res
        })
      })
  },
  addActivity(){
    wx.navigateTo({
      url: '/pages/addActivity/addActivity',
    })
  },
  showDetail(param){
    wx.navigateTo({
      url: '/pages/activityDetail/activityDetail?id='+param.currentTarget.dataset.id,
    })
  }
})
